using Since.Netcode;
using Unity.Netcode;
using UnityEngine;

public class Enemy : NetworkBehaviourPro<Enemy, EnemyServer, EnemyClient, EnemyClientSimulate, EnemyAuthority, EnemyNonAuthority>
{

	[ServerRpc]
	public void CallDespawnServerRpc()
	{
		GetComponent<NetworkObject>().Despawn();
	}

	public override void OnNetworkSpawn()
	{
		var color = Color.white;
		if (OwnerClientId == 0)
			color = Color.blue;
		else if (OwnerClientId == 1)
			color = Color.green;
		else if (OwnerClientId == 2)
			color = Color.yellow;
		else if (OwnerClientId == 3)
			color = Color.cyan;

		// 获取渲染器组件
		var renderer = GetComponent<Renderer>();
		if (renderer != null)
		{
			// 设置材质为红色
			renderer.material.color = color;
		}

		transform.localScale = IsOwner ? Vector3.one * 1.5f : Vector3.one;

		base.OnNetworkSpawn();
	}
}
